package chapter02

object Test26_Map {
  def main(args: Array[String]): Unit = {
    var map = Map("a" -> 100, "b" -> 60, "c" -> 85)
    //取map中的值
    val option = map.get("a")
    println(option)
    println(map.get("d"))
    println(map.getOrElse("a",-1))
    val map1 = map.updated("a", 120)
    println(map1.get("a"))
    println(map.get("a"))
    //遍历map
    for(i<-map.keys){
      println(i)
    }
    for(i<-map.values){
      println(i)
    }
    for(i<-map.keySet){
      println(map.get(i))
    }
    map.foreach((kv)=>println(kv))
    for(kv<-map){
      println(kv)
    }
  }
}
